import sys
import time
sys.path.append("../modules/")
from BayesNetwork import BayesNetwork

BN = BayesNetwork()
BN.parse_encog("../data/EncogBayesData/alarm.eg")


#EM
bn_structure = BN.BayesianNetwork
variables, data = BN.loadDataset("alarm_verbose.csv")
#bn_structure = BN.generateRandomStructure(BN.BayesianNetwork.keys(), 0.1)
#print "Random structure generated."
#bn_structure = BN.randomParameterBNInitialization(bn_structure)
#print "Random parameters initialized."
st = time.time()
print "Starting EM..."
ESS, bn_structure = BN.expectationMaximization(variables, data, 0.01, bn_structure, None)
print time.time() - st
#BN.printBN(bn_structure)

